﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YanShu.Entity
{
    [JsonObject("CommonDTO")]
    public class CommonDTO
    {

        public const String SUCCESS = "0000";
        public const String FAIL = "9999";
        public const String SUCCESS_MSG = "成功";
        public const String FAIL_MSG = "失败";
        [JsonProperty("code")]
        private String code;
        [JsonProperty("msg")]
        private String msg;
        [JsonProperty("data")]
        private Object data;

        public CommonDTO()
        {

        }

        public CommonDTO(String code, String msg)
        {
            this.code = code;
            this.msg = msg;
        }

        public CommonDTO(String code, String msg, Object data)
        {
            this.code = code;
            this.msg = msg;
            this.data = data;
        }

        public String GetCode()
        {
            return code;
        }

        public void SetCode(String code)
        {
            this.code = code;
        }

        public String GetMsg()
        {
            return msg;
        }

        public void SetMsg(String msg)
        {
            this.msg = msg;
        }

        public Object GetData()
        {
            return data;
        }

        public void SetData(Object data)
        {
            this.data = data;
        }

        public static CommonDTO Success()
        {
            return new CommonDTO(SUCCESS, SUCCESS_MSG);
        }

        public static CommonDTO Success(String msg)
        {
            return new CommonDTO(SUCCESS, msg);
        }

        public static CommonDTO Fail()
        {
            return new CommonDTO(FAIL, FAIL_MSG);
        }

        public static CommonDTO Fail(String msg)
        {
            return new CommonDTO(FAIL, msg);
        }

    }
}
